<template>
  <div id="building">
    <div style="padding-top: 120px;color: black ; padding-bottom: 10px">
      <h2 class="title">万里之家后台管理系统</h2>
    </div>
    <el-form :model="ruleForm" status-icon label-width="100px">
      <el-form-item label="账号" prop="username" style="padding-left: 200px">
        <el-input
          v-model="ruleForm.username"
          placeholder="请输入用户名"
          maxlength="10"
          style="padding-right: 100px"
        ></el-input>
      </el-form-item>

      <el-form-item label="密码" prop="pass" style="padding-left: 200px">
        <el-input
          type="password"
          v-model="ruleForm.password"
          placeholder="请输入密码"
          maxlength="15"
        ></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm()"
        style="margin-left: 140px"><span style="font-size: 20px">登录</span></el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      ruleForm: {},
    };
  },
  methods: {
    submitForm() {
      //get

      this.$axios
        .get("http://localhost:9000/login?username="+this.ruleForm.username+"&password="+this.ruleForm.password)
        .then(response=>{
          console.log(1111)
          if(response.data.success==1){
            this.$router.push({ path: "/main" });
          }
          else {
              alert("账号密码错误")
          }
        })
        .catch(response=>{
          alert("方法错误")
        })

    },
  },
};
</script>

<style >
#building {
  background: url("../assets/2.png");
  width: 100%;
  height: 100%;
  position: fixed;
  background-size: 100% 100%;
}
.el-form {
  width: 35%;
  height: 35%;
  height: 400px;
  margin-left: 420px;
  /* background: red; */
}
.el-form-item__label{
  color: black;
  font-size: 20px;
  font-weight: bold;
}
.el-form-item .el-form-item--feedback{
  padding-left: 0px !important;
}
</style>
